package gongchangmoshi

/**
简单工厂模式
*/

type Book interface {
	Name() string
}

type chineseBook struct {
	name string
}

func (ch *chineseBook) Name() string {
	return ch.name
}

type englishBook struct {
	name string
}

func (en *englishBook) Name() string {
	return en.name
}

func getBook(name string) Book {
	var book Book
	switch name {
	case "chinese":
		book = &chineseBook{name: "中文书"}
	case "english":
		book = &englishBook{name: "英语书"}
	}
	return book
}
